<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: content.php 502 2014-01-31 15:50:06Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 502 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2014-01-31 15:50:06 +0000 (Fri, 31 Jan 2014) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

$box_smarty = new Smarty();
$content_string = '';

$box_smarty->assign('language', $_SESSION['language']);

if(!CacheCheck()) {
	$cache=false;
	$box_smarty->caching = false;
} else {
	$cache=true;
	$box_smarty->caching = true;
	$box_smarty->cache_lifetime = CACHE_LIFETIME;
	$box_smarty->cache_modified_check = CACHE_CHECK;
	$cache_id = 'box_content_'.$_SESSION['language'].$_SESSION['customers_status']['customers_status_id'];
}

if(!$box_smarty->isCached(CURRENT_TEMPLATE.'/boxes/box_content.html', $cache_id) || !$cache) {

	$box_smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');
	$box_smarty->assign('html_tpl_path', CURRENT_TEMPLATE.'/html');

	if(GROUP_CHECK == 'true')
		$group_check = " AND group_ids LIKE '%c_".$_SESSION['customers_status']['customers_status_id']."_group%'";

	$content = $db->db_query("SELECT
									content_id,
									categories_id,
									parent_id,
									content_title,
									content_out_link,
									content_link_target,
									content_link_type,
									content_group
								FROM
									".TABLE_CONTENT_MANAGER."
								WHERE
									languages_id='".(int) $_SESSION['languages_id']."'
								AND
									parent_id = '0'
								AND
									file_flag = '1'
									".$group_check."
								AND
									content_status = '1'
								ORDER
									BY sort_order", true);

	$getChild = $db->db_query("SELECT parent_id FROM ".TABLE_CONTENT_MANAGER." WHERE content_group = '".$_GET['coID']."'", true);
	$content_string = '<ul>';
	while(!$content->EOF) {
		$active_link = '';

		if($_GET['coID'] == $content->fields['content_group'])
			$active_link = ' class="Current"';

		if($content->fields['content_out_link'])
			$content_string .= '<li class="list"><a'.$active_link.' title="'.$content->fields['content_title'].'" rel="'.$content->fields['content_link_type'].'" target="'.$content->fields['content_link_target'].'" href="'.$content->fields['content_out_link'].'">'.$content->fields['content_title'].'</a>';
		else
			$content_string .= '<li class="list"><a'.$active_link.' title="'.$content->fields['content_title'].'" href="'.href_link(FILENAME_CONTENT, 'coID='.$content->fields['content_group']).'">'.$content->fields['content_title'].'</a>';

		if($_GET['coID'] == $content->fields['content_group'] || $getChild->fields['parent_id'] == $content->fields['content_group']) {
			$get_child = get_content_child($content->fields['content_group']);
			if(is_array($get_child)){
				$content_string .= '<ul class="sub">';
				foreach($get_child AS $child_data){
					if($child_data['content_out_link'])
						$content_string .= '<li class="main_level_2"><a'.($child_data['content_group'] == $_GET['coID'] ? ' class="Current"':'').' title="'.$child_data['content_title'].'" rel="'.$child_data['content_link_target'].'" target="'.$child_data['content_link_type'].'" href="'.$child_data['content_out_link'].'">'.$child_data['content_title'].'</a></li>';
					else
						$content_string .= '<li class="main_level_2"><a'.($child_data['content_group'] == $_GET['coID'] ? ' class="Current"':'').' title="'.$child_data['content_title'].'" href="'.href_link(FILENAME_CONTENT, 'coID='.$child_data['content_group']).'">'.$child_data['content_title'].'</a></li>';
				}
				$content_string .= '</ul>';
			}
		}
		$content_string .= '</li>';
		$content->MoveNext();
	}
	$content_string .= '</ul>';

	if ($content_string != '')
		$box_smarty->assign('BOX_CONTENT', $content_string);
}

if(!$cache)
	$box_content = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_content.html');
else
	$box_content = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_content.html', $cache_id);